<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
		<title>餐厅预定</title>
		<script src="__INDEX__/js/mui.min.js"></script>
		<link href="__INDEX__/css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="__INDEX__/css/iconfont.css" />
		<link rel="stylesheet" href="__INDEX__/css/style.css" />
		<link rel="stylesheet" href="__INDEX__/css/index.css" /> 
	</head>

	<body class="mui-ios mui-ios-11 mui-ios-11-0">
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">餐厅预定</h1>
		</header>     

		<div class="mui-content">
			<!--<div class="shoplist_top">
				<ul class="slist_tlis clearfix">
					<li>分类<span class="iconfont icon-jiantou"></span></li>
					<li>附近<span class="iconfont icon-jiantou"></span></li>
					<li>时间<span class="iconfont icon-jiantou"></span></li>
				</ul>

			</div>-->
			<div class="shoplist_box">
				<ul class="index_sjlist" id="store_ul">
					<!--<li>
						<a href="yuyue" class="clearfix">
							<div class="index_sjimg"><img src="__INDEX__/img/y3.png"></div>
							<div class="index_sjinfo">
								<div class="index_spname"><span style="float: right;font-size: 12px;">0m</span>友果水果批发</div>
								<div class="index_spadr clearfix">
									<div class="index_spadr_l"><span class="iconfont icon-dingwei"></span> 北湖区, 青年大道, </div>
									<div class="index_spadr_r"><button class="btn-sub">预定</button></div>
								</div>
							</div>
						</a>
					</li>-->
				</ul>
			</div>
		</div>
	</body>

</html>
{include file="public/footer" /}
<script src="__INDEX__/js/assist.js "></script>
<script>
	var btype = "{$btype}";
	if(btype == 0) {
		setCookie('longitude', 0);
		setCookie('latitude', 0);
		get_data();
	}else{
		var longitude = getCookie('longitude');
		var latitude = getCookie('latitude');
		if(latitude){
			get_data();
		}
	} 
	var list=[]; 
    
	var page=1;
	var hasdata=true;
	function get_data() {   
		var longitude = getCookie("longitude");
		var latitude = getCookie("latitude");
		if(hasdata==false){
			return;
		}
		$.ajax({
			type: "post",
			data: { 
				longitude: longitude,
				latitude: latitude, 
				page: page
			},
			url: "{:url('index/index/ctyd')}",
			success: function(data) { 
				var html = "";
				if(data.list&&data.list.length>0) {
					page++
					list=list.concat(data.list); 
					for(var o in list) { 
						var agent = list[o]; 
						var juli = agent.juli;  
						var thumb = agent.thumb;  
						if(juli > 1000) {
							juli = juli / 1000;
							unit = 'km';
						}
						if(juli == null || juli==''){
							juli='';
						}
						var url = "/index/index/yuyue?store_id="+agent.id;
						html +=  '<li>'
						     +'<a href="'+url+'" class="clearfix">'
						     +'<div class="index_sjimg"><img src="'+thumb+'"></div>'
						     +'<div class="index_sjinfo">'
						     +'<div class="index_spname"><span style="float: right;font-size: 12px;">'+juli+'km</span>'+agent.store_name+'</div>'
						     +'<div class="index_spadr clearfix">'
						     +'<div class="index_spadr_l"><span class="iconfont icon-dingwei"></span>'+agent.store_address+'</div>'
						     +'<div class="index_spadr_r"><button class="btn-sub">预定</button></div>'
						     +'</div>'
						     +'</div>'
						     +'</a>'
						     +'</li>'
					}
					$('.index_sjlist').html(html); 
				} 
				if(list.length==0){
					hasdata=false;
					$(".index_sjlist").html('<div style="background-color: #efeff4;text-align:center;margin-top:220px">暂无数据</div>');
				}
			}
		});
	} 

	$(window).scroll(function() {
		var lng = getCookie('longitude');
		if(hasdata&&lng){
			var scrollTop = $(window).scrollTop(); //滚动条高度
			var bodyheight = $(document).height(); //文档的高度
			var windowheight = window.innerHeight; //$(window).height();              //当前窗体的高度
			if((bodyheight - windowheight - scrollTop) == 0) {
				get_data();
			}
		}
		
	})  
</script>